package com.message.redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.stereotype.Service;

/**
 * Created by 张波 on 2019/10/13.
 */
@Service
public class RedisService {

    @Autowired
    StringRedisTemplate redisTemplate;

    private ValueOperations<String,String> stringRedis;

    public void init() {
        stringRedis = redisTemplate.opsForValue();
    }

    public void test() {
        init();
        stringRedis.set("name","zhangbo");
        stringRedis.set("age","28");
        System.out.println("name:" + stringRedis.get("name") + ",age:" + stringRedis.get("age"));
    }

}
